//
//  main.swift
//  IteratorPattern
//
//  Created by mac on 2017/11/14.
//  Copyright © 2017年 RRC. All rights reserved.
//

import Foundation

print("Hello, World!")

//let project = Project(name: "星球大战", num: 10, cost: 100000)
//let proInfo =  project.getProjectInfo()
//print(proInfo)


let project:IProject = Project()
project.add(name: "星球大战dddd", num: 10, cost: 10000)
project.add(name: "扭转时空", num: 100, cost: 1000000000)
let projectIterator:ProjectIterator = project.iterator()
//let p = projectIterator.next() as! IProject
//print(p.getProjectInfo())
while let pro = projectIterator.next(){

    print((pro as! IProject).getProjectInfo())
}

/**
 迭代器模式定义：它提供一种方法访问一个容器对象中各个元素，而以不需暴露该对象的内部细节。
 注：现代的开发语言已经把迭代器融入到各个语言和工具中，可以只接使用而不必再自己动手写迭代器了
 */



